/**
 * 动态读取模块
 *
 * @returns 模块方法
 */
const readModel = () => {
  try {
    const files = require.context('.', false, /\.js$/)
    let modules = {}

    files.keys().forEach(key => {
      if (key === './index.js') return

      modules = Object.assign(modules, files(key))
    })

    return modules
  } catch (error) {
    console.error(error)
    throw new Error('动态读取模块失败')
  }
}

export default readModel()
